\section{Previous work}

\subsection{MIT LOOP with variations}
\label{sec-mit-loop}

One of the first implementations of the \commonlisp{} \texttt{loop}
macro is the one that is often referred to as ``\mitloop{}''
\cite{Burke:Moon:MIT.loop}.  A popular variation of this
implementation includes modifications by \symbolics{}.%
\footnote{\symbolics{} was a company that sold Lisp machines.  See
  https://en.wikipedia.org/wiki/Symbolics for a thorough description
  of the company and its products.}

This implementation of the \texttt{loop} macro is sometimes more
permissive than the \commonlisp{} standard.  For example, the standard
requires all \emph{variable clauses} to precede all \emph{main
  clauses}. \seeapp{loop-syntax}  Code such as the one in this example:

\begin{verbatim}
    (loop until (> i 20)
          for i from 0
          do (print i))
\end{verbatim}

\noindent
is thus not conforming according to the standard, since \texttt{until}
is a \emph{main clause} whereas \texttt{for} is a \emph{variable
  clause}.  However, \mitloop{} and its variation accepts the code in
the example.

Another example of non-conforming behavior is illustrated by the
following code:

\begin{verbatim}
    (loop for i from 0 below 10
          sum i
          finally (print i))
\end{verbatim}

The \commonlisp{} standard clearly states that the loop variable does
not take on the value of the upper limit, here $10$, so the value
printed in the \texttt{finally} clause should be $9$.  However,
\texttt{loop} implementations derived from \mitloop{} print $10$
instead.

Notice that the two examples above are non-conforming in two different
ways, as explained in section 1.5 of the \commonlisp{} standard.

In the first case, we have an example of \emph{a non-conforming
  program} as explained in section 1.5.2 for the simple reason that
the standard does not specify what an implementation must do when the
clause order is violated.  By default, then, the behavior is said to
be \emph{undefined}, meaning that the implementation is free to reject
the non-conforming program or to accept it and interpret it in some
(perhaps unexpected) way.  The \mitloop{} implementation is therefore
conforming in this respect.

In the second case, we have an example of \emph{a non-conforming
  implementation} as explained in section 1.5.1.  The reason is that
the standard clearly stipulates that every implementation must print
$9$, whereas \mitloop{} prints $10$.

In addition to the non-conforming problems, \mitloop{} has issues with
modularity, in that the implementation is \emph{monolithic}, and that
holds true for its variations too.  The code is contained in a single
file with around $2000$ lines of code in it.

Code generation uses a significant number of special variables holding
various pieces of information that are ultimately assembled into the
final expansion of the macro.

\subsection{\ecl{} and \clasp{}}

\ecl{}%
\footnote{\ecl{} stands for ``Embedded Common Lisp.\\
See: //https://gitlab.com/embeddable-common-lisp/ecl}
includes two implementations of the \texttt{loop} macro, namely
the initial \mitloop{} with only minor modifications, and a variation
of \mitloop{} that also includes code written
by \symbolics{} also with minor modifications.

\clasp{}%
\footnote{See: https://github.com/drmeister/clasp} is a recent
implementation of \commonlisp{}.  It is derived from \ecl{} in that
the \clanguage{} \cite{iso:c} code of \ecl{} has been translated to
\cplusplus{} \cite{iso:cplusplus} whereas most of the \commonlisp{}
code has been included with no modification, including the code for
the \texttt{loop} macro.

\ecl{} \texttt{loop} being derived from \mitloop{}, the non-conforming
examples shown in \refSec{sec-mit-loop} are also accepted by \ecl{} and
\clasp{}.

\subsection{\sbcl{}}

\sbcl{}%
\footnote{\sbcl{} stands for Steel-Bank \commonlisp{}.\\ See:
  http://www.sbcl.org/} includes an implementation of the
\texttt{loop} macro that was originally derived from \mitloop{}, but
that also includes code created by \symbolics{}.  Because of the way
the code has evolved, it is hard to determine whether, at some point,
the code of the \texttt{loop} macro of \sbcl{} and that of \ecl{} were
the same, but a rough comparison suggests that this is the case.

The \texttt{loop} implementation of \sbcl{} being derived from
\mitloop{}, the non-conforming examples shown in \refSec{sec-mit-loop}
are also accepted by \sbcl{}.

\subsection{\clisp{}}

\clisp{} has its own implementation of the \texttt{loop} macro.  The
bulk of the implementation can be found in a function named
\texttt{expand-loop}.  This function consists of more than $900$ lines
of code.

\subsection{\ccl{}}

Like many other implementations, \ccl{}%
\footnote{\ccl{} stands for Clozure \commonlisp.\\ See:
  http://ccl.clozure.com/} includes the variation of \mitloop{}
containing modifications by \symbolics{} from a brief inspection, we
believe that the original code is the same as that of \sbcl{} and
\ecl{}.

\subsection{\lispworks}

Evaluating the two examples in \refSec{sec-mit-loop} using
\lispworks{}%
\footnote{See: http://www.lispworks.com/}
gives the same result as the implementations using \mitloop{},
suggesting that \lispworks{} also uses a derivative of that
\texttt{loop} implementation.
